import { extend, localize } from 'vee-validate'
import { required, email, min, length, confirmed, max, is_not as isNot } from 'vee-validate/dist/rules'
import cn from 'vee-validate/dist/locale/zh_CN.json'

extend('required', required)
extend('email', email)
extend('min', min)
extend('length', length)
extend('confirmed', confirmed)
extend('max', max)
extend('is_not', isNot)
localize('zh_CN', {
  messages: {
    ...cn.messages,
    required: field => '请输入' + field,
    email: () => '请输入正确的邮箱格式',
    min: () => '长度不符合最小要求',
    length: (field, len) => {
      return `${field}不符合长度要求${len.length}`
    },
    confirmed: () => '两次输入不一致'

  },
  fields: {
    catalog: {
      is_not: `请选择{_field_}`
    }
  },
  names: {
    email: '邮箱',
    password: '密码',
    username: '用户名',
    code: '验证码',
    title: '标题',
    catalog: '类别'
  }
})
